package Frames;

import Classes.Cliente;
import Classes.Servico;
import Classes_Conexao.ClienteDAO;
import Classes_Conexao.ServicoDAO;
import java.awt.Dimension;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Saulo Queiroz
 */
public class Servicos extends javax.swing.JInternalFrame {

    Servico servico = new Servico();
    Cliente cliente = new Cliente();
    Date data;
    private DefaultTableModel modelo = null;
    private DefaultTableModel modeloServ = null;

    public Servicos(Cliente cliente) {
        initComponents();

//        txtCliente.setText(cliente.getNome());
//        txtCodigoCliente.setText(Integer.toString(cliente.getCodigo()));
//        txtTelefone.setText(cliente.getFone1());
//        txtCelular.setText(cliente.getCelular());
//        txtEndereco.setText(cliente.getEndereco());
//        txtCidade.setText(cliente.getCidade());
//        txtBairro.setText(cliente.getBairro());
//        txtObs.setText(cliente.getBairro());
    }

    public Servicos() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dadosCliente = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        txtCodigoCliente = new javax.swing.JTextField();
        btnBCodigo = new javax.swing.JButton();
        txtCliente = new javax.swing.JTextField();
        txtEndereco = new javax.swing.JTextField();
        txtCidade = new javax.swing.JTextField();
        txtBairro = new javax.swing.JTextField();
        txtTelefone = new javax.swing.JTextField();
        txtCelular = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtObs = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        dadosServico = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        txtDataH = new javax.swing.JTextField();
        txtNotaF = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        txtAcessorio = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        txtEquipamento = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        txtDefeito = new javax.swing.JTextField();
        txtNServico = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        CboxStatus = new javax.swing.JComboBox();
        btnIncluir = new javax.swing.JButton();
        btnLocalizar = new javax.swing.JButton();
        btnExcluir = new javax.swing.JButton();
        btnGravar = new javax.swing.JButton();
        btnNaoGravar = new javax.swing.JButton();
        btnImprimir = new javax.swing.JButton();
        btnFechar = new javax.swing.JButton();
        LocalizarServico = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        cPesquisaServ = new javax.swing.JComboBox();
        jScrollPane4 = new javax.swing.JScrollPane();
        jScrollPane5 = new javax.swing.JScrollPane();
        TabelaServ = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        txtPesquisaNome = new javax.swing.JTextField();
        Localizar = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        txtPesquisa = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setTitle("Controle de ordem de Serviços");
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameOpened(evt);
            }
        });

        dadosCliente.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados do Cliente"));

        jLabel3.setText("Código do Cliente");

        jLabel4.setText("Cliente");

        jLabel6.setText("Endereço");

        jLabel7.setText("Cidade");

        jLabel8.setText("Bairro");

        jLabel9.setText("Telefone");

        jLabel11.setText("Celular");

        txtCodigoCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCodigoClienteActionPerformed(evt);
            }
        });
        txtCodigoCliente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtCodigoClienteKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtCodigoClienteKeyTyped(evt);
            }
        });

        btnBCodigo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/lupa pequena.png"))); // NOI18N
        btnBCodigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBCodigoActionPerformed(evt);
            }
        });

        jLabel10.setText("Obs.");

        txtObs.setColumns(20);
        txtObs.setRows(5);
        jScrollPane1.setViewportView(txtObs);

        javax.swing.GroupLayout dadosClienteLayout = new javax.swing.GroupLayout(dadosCliente);
        dadosCliente.setLayout(dadosClienteLayout);
        dadosClienteLayout.setHorizontalGroup(
            dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel10)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 673, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGroup(dadosClienteLayout.createSequentialGroup()
                .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, dadosClienteLayout.createSequentialGroup()
                        .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(dadosClienteLayout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addGap(122, 122, 122)
                                .addComponent(jLabel7))
                            .addGroup(dadosClienteLayout.createSequentialGroup()
                                .addComponent(txtEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(4, 4, 4)
                                .addComponent(txtCidade, javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtBairro, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)
                            .addComponent(jLabel8)))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, dadosClienteLayout.createSequentialGroup()
                        .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(dadosClienteLayout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(10, 10, 10)
                                .addComponent(jLabel4)
                                .addGap(318, 318, 318)
                                .addComponent(jLabel9))
                            .addGroup(dadosClienteLayout.createSequentialGroup()
                                .addComponent(txtCodigoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnBCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 343, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(dadosClienteLayout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(jLabel11))
                            .addGroup(dadosClienteLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtCelular, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addGap(18, 18, 18))
        );
        dadosClienteLayout.setVerticalGroup(
            dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dadosClienteLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(dadosClienteLayout.createSequentialGroup()
                        .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addGroup(dadosClienteLayout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(jLabel9)))
                        .addGap(11, 11, 11)
                        .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(txtCodigoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(txtCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(btnBCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(dadosClienteLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(26, 26, 26)))
                .addGap(11, 11, 11)
                .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(dadosClienteLayout.createSequentialGroup()
                        .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7))
                        .addGroup(dadosClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(dadosClienteLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(12, 12, 12))
        );

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel1.setText("Ordem de serviço Número");

        dadosServico.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados do Serviço"));

        jLabel14.setText("Data e Hora da Entrada");

        jLabel15.setText("Nota Fiscal");

        txtNotaF.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNotaFKeyTyped(evt);
            }
        });

        jLabel17.setText("Defeito reclamado");

        txtAcessorio.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtAcessorioKeyTyped(evt);
            }
        });

        jLabel13.setText("Acessórios");

        txtEquipamento.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtEquipamentoKeyTyped(evt);
            }
        });

        jLabel12.setText("Equipamento");

        txtDefeito.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDefeitoKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout dadosServicoLayout = new javax.swing.GroupLayout(dadosServico);
        dadosServico.setLayout(dadosServicoLayout);
        dadosServicoLayout.setHorizontalGroup(
            dadosServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dadosServicoLayout.createSequentialGroup()
                .addGroup(dadosServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dadosServicoLayout.createSequentialGroup()
                        .addGroup(dadosServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtEquipamento, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12))
                        .addGap(10, 10, 10)
                        .addGroup(dadosServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(dadosServicoLayout.createSequentialGroup()
                                .addComponent(jLabel17)
                                .addGap(384, 384, 384))
                            .addComponent(txtDefeito, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)))
                    .addGroup(dadosServicoLayout.createSequentialGroup()
                        .addGroup(dadosServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel14)
                            .addComponent(txtDataH, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(28, 28, 28)
                        .addGroup(dadosServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel15)
                            .addComponent(txtNotaF, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel13)
                    .addComponent(txtAcessorio, javax.swing.GroupLayout.DEFAULT_SIZE, 678, Short.MAX_VALUE))
                .addContainerGap())
        );
        dadosServicoLayout.setVerticalGroup(
            dadosServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dadosServicoLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(dadosServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dadosServicoLayout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtNotaF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(dadosServicoLayout.createSequentialGroup()
                        .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtDataH, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(txtAcessorio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(dadosServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17))
                .addGap(2, 2, 2)
                .addGroup(dadosServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtDefeito, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtEquipamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(31, 31, 31))
        );

        try {
            txtNServico.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("#####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel2.setText("Status");

        CboxStatus.setFont(new java.awt.Font("Tahoma", 0, 14));
        CboxStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Aberto", "Retirado", "Deposito" }));
        CboxStatus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CboxStatusActionPerformed(evt);
            }
        });

        btnIncluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/New-icon.png"))); // NOI18N
        btnIncluir.setText("Incluir");
        btnIncluir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnIncluir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnIncluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIncluirActionPerformed(evt);
            }
        });

        btnLocalizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Search-icon.png"))); // NOI18N
        btnLocalizar.setText("Localizar");
        btnLocalizar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnLocalizar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnLocalizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLocalizarActionPerformed(evt);
            }
        });

        btnExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Delete-icon.png"))); // NOI18N
        btnExcluir.setText("Excluir");
        btnExcluir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnExcluir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExcluirActionPerformed(evt);
            }
        });

        btnGravar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Save-icon.png"))); // NOI18N
        btnGravar.setText("Gravar");
        btnGravar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnGravar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnGravar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGravarActionPerformed(evt);
            }
        });

        btnNaoGravar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Remove-icon.png"))); // NOI18N
        btnNaoGravar.setText("Não Gravar");
        btnNaoGravar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnNaoGravar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnNaoGravar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNaoGravarActionPerformed(evt);
            }
        });

        btnImprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Print-icon.png"))); // NOI18N
        btnImprimir.setText("Imprimir");
        btnImprimir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnImprimir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnImprimirActionPerformed(evt);
            }
        });

        btnFechar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Log-Out-icon.png"))); // NOI18N
        btnFechar.setText("Fechar");
        btnFechar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnFechar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnFechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFecharActionPerformed(evt);
            }
        });

        LocalizarServico.setBorder(javax.swing.BorderFactory.createTitledBorder("Localizar"));
        LocalizarServico.setPreferredSize(new java.awt.Dimension(651, 227));

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Pesquisar por status"));

        cPesquisaServ.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Aberto", "Retirado", "Deposito" }));
        cPesquisaServ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cPesquisaServActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cPesquisaServ, 0, 216, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(cPesquisaServ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jScrollPane4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jScrollPane4MouseClicked(evt);
            }
        });

        TabelaServ.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        TabelaServ.getTableHeader().setReorderingAllowed(false);
        TabelaServ.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                TabelaServMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                TabelaServMouseEntered(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                TabelaServMousePressed(evt);
            }
        });
        jScrollPane5.setViewportView(TabelaServ);

        jScrollPane4.setViewportView(jScrollPane5);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Pesquisa Por Nome"));

        txtPesquisaNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtPesquisaNomeActionPerformed(evt);
            }
        });
        txtPesquisaNome.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtPesquisaNomeKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(txtPesquisaNome, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(txtPesquisaNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout LocalizarServicoLayout = new javax.swing.GroupLayout(LocalizarServico);
        LocalizarServico.setLayout(LocalizarServicoLayout);
        LocalizarServicoLayout.setHorizontalGroup(
            LocalizarServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(LocalizarServicoLayout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(LocalizarServicoLayout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 674, Short.MAX_VALUE)
                .addGap(20, 20, 20))
        );
        LocalizarServicoLayout.setVerticalGroup(
            LocalizarServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(LocalizarServicoLayout.createSequentialGroup()
                .addGroup(LocalizarServicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)
                .addContainerGap())
        );

        Localizar.setBorder(javax.swing.BorderFactory.createTitledBorder("Localizar"));
        Localizar.setPreferredSize(new java.awt.Dimension(651, 227));

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Pesquisa"));

        txtPesquisa.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtPesquisaKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(txtPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 357, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(txtPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jScrollPane2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jScrollPane2MouseClicked(evt);
            }
        });

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jTable1.getTableHeader().setReorderingAllowed(false);
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jTable1MouseEntered(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jTable1MousePressed(evt);
            }
        });
        jScrollPane3.setViewportView(jTable1);

        jScrollPane2.setViewportView(jScrollPane3);

        javax.swing.GroupLayout LocalizarLayout = new javax.swing.GroupLayout(Localizar);
        Localizar.setLayout(LocalizarLayout);
        LocalizarLayout.setHorizontalGroup(
            LocalizarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(LocalizarLayout.createSequentialGroup()
                .addGroup(LocalizarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(LocalizarLayout.createSequentialGroup()
                        .addGap(150, 150, 150)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(LocalizarLayout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 607, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(71, Short.MAX_VALUE))
        );
        LocalizarLayout.setVerticalGroup(
            LocalizarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(LocalizarLayout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(btnIncluir, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9)
                .addComponent(btnLocalizar, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9)
                .addComponent(btnExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9)
                .addComponent(btnGravar, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9)
                .addComponent(btnNaoGravar)
                .addGap(13, 13, 13)
                .addComponent(btnImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9)
                .addComponent(btnFechar, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jLabel1)
                .addGap(4, 4, 4)
                .addComponent(txtNServico, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(242, 242, 242)
                .addComponent(jLabel2)
                .addGap(10, 10, 10)
                .addComponent(CboxStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(7, 7, 7)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(LocalizarServico, javax.swing.GroupLayout.DEFAULT_SIZE, 706, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(Localizar, javax.swing.GroupLayout.DEFAULT_SIZE, 706, Short.MAX_VALUE))
                    .addComponent(dadosCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(dadosServico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnExcluir, btnFechar, btnGravar, btnImprimir, btnIncluir, btnLocalizar, btnNaoGravar});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnIncluir)
                    .addComponent(btnLocalizar)
                    .addComponent(btnExcluir)
                    .addComponent(btnGravar)
                    .addComponent(btnNaoGravar)
                    .addComponent(btnImprimir)
                    .addComponent(btnFechar))
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(txtNServico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel2))
                    .addComponent(CboxStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(LocalizarServico, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(Localizar, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(dadosCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(6, 6, 6)
                .addComponent(dadosServico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(30, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnIncluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIncluirActionPerformed
//        if (btnLocalizar.getText().equals("Voltar")) {
//        btnLocalizar.setText("Localizar");
//        dadosCliente.setVisible(true);
//        Localizar.setVisible(false);
//        } else {
//        btnLocalizar.setText("Localizar");
//        dadosCliente.setVisible(true);
//        Localizar.setVisible(false);
//        }
        txtAcessorio.setText("");
        txtBairro.setText("");
        txtCelular.setText("");
        txtCidade.setText("");
        txtCliente.setText("");
        txtCodigoCliente.setText("");
        txtDataH.setText("");
        txtDefeito.setText("");
        txtEndereco.setText("");
        txtEquipamento.setText("");
        txtNServico.setText("");
        txtNotaF.setText("");
        txtObs.setText("");
        txtTelefone.setText("");

        //desativar e ativar botões
        btnBCodigo.setEnabled(true);
        btnIncluir.setEnabled(false);
        btnLocalizar.setEnabled(false);
        btnExcluir.setEnabled(false);
        btnGravar.setEnabled(true);
        btnNaoGravar.setEnabled(true);
        btnFechar.setEnabled(false);


        //ativar e desativar campos
        txtAcessorio.setEnabled(true);
        txtBairro.setEnabled(true);
        txtCelular.setEnabled(true);
        txtCidade.setEnabled(true);
        txtCliente.setEnabled(true);
        txtCodigoCliente.setEnabled(true);
        txtDataH.setEnabled(false);
        txtDefeito.setEnabled(true);
        txtEndereco.setEnabled(true);
        txtEquipamento.setEnabled(true);
        txtNServico.setEnabled(false);
        txtNotaF.setEnabled(true);
        txtObs.setEnabled(true);
        txtTelefone.setEnabled(true);
        CboxStatus.setEnabled(true);
        //colocar data e hora no campo de data e hora
        SimpleDateFormat dataf = new SimpleDateFormat("dd/MM/yyyy 'e' HH:mm:ss");
        data = new Date();
        txtDataH.setText(dataf.format(data));
        //mudar nomes dos botões
        btnGravar.setText("Gravar");
        //busca do codigo no banco
        try {
            ServicoDAO servicoDao = new ServicoDAO();
            ArrayList<Servico> servico = servicoDao.retornaCodigo();

            for (Servico s : servico) {
                txtNServico.setText(Integer.toString(s.getCodigoServico() + 1));
            }

        } catch (SQLException ex) {
            ex.printStackTrace();
        }
}//GEN-LAST:event_btnIncluirActionPerformed

    private void btnLocalizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLocalizarActionPerformed
        if (btnLocalizar.getText().equals("Localizar")) {
            btnLocalizar.setText("Voltar");
            dadosCliente.setVisible(false);
            dadosServico.setVisible(false);
            LocalizarServico.setVisible(true);
            btnIncluir.setEnabled(false);
            try {
                ServicoDAO servicoDao = new ServicoDAO();
                ArrayList<Servico> servico = servicoDao.retornaTodosServicos();

                modeloServ.setNumRows(0);

                for (Servico s : servico) {
                    // para inserir o codigo do cliente que faz parte de outro metodo na classeDao
                modeloServ.addRow(new String[]{Integer.toString(s.getCodigoServico()), s.getStatus(), s.getEquipamento(), s.getAcessorio(), s.getDataHora(), s.getNotaFiscal(), s.getDefeitoReclamar(), Integer.toString(s.getCodigoCliente()), s.getCliente()});
            }
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
        } else {
            btnLocalizar.setText("Localizar");
            dadosCliente.setVisible(true);
            dadosServico.setVisible(true);
            LocalizarServico.setVisible(false);
            btnIncluir.setEnabled(true);
            Localizar.setVisible(false);
        }
        btnExcluir.setEnabled(false);
        btnGravar.setText("Gravar");
    }//GEN-LAST:event_btnLocalizarActionPerformed

    private void btnExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExcluirActionPerformed
        UIManager.put("OptionPane.yesButtonText", "Sim");
        UIManager.put("OptionPane.noButtonText", "Não");
        UIManager.put("OptionPane.cancelButtonText", "Cancelar");
        int resultado = JOptionPane.showConfirmDialog(null, "Você deseja excluir o registro?", "Excluir", 1, 1);
        int resultado2 = JOptionPane.showConfirmDialog(null, "Tem certeza?", "Excluir", 1, 1);
        if (resultado == 0 && resultado2 == 0) {
            int linhaSelecionada = TabelaServ.getSelectedRow();
            Servico servico = new Servico();

            servico.setCodigoServico(Integer.parseInt(TabelaServ.getValueAt(linhaSelecionada, 0).toString()));

            try {
                ServicoDAO servicoDao = new ServicoDAO();
                servicoDao.excluir(servico);
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
            modeloServ.removeRow(linhaSelecionada);
            // ativar e desativar os campos de texto
            txtAcessorio.setText("");
            txtBairro.setText("");
            txtCelular.setText("");
            txtCidade.setText("");
            txtCliente.setText("");
            txtCodigoCliente.setText("");
            txtDataH.setText("");
            txtDefeito.setText("");
            txtEndereco.setText("");
            txtEquipamento.setText("");
            txtNServico.setText("");
            txtNotaF.setText("");
            txtObs.setText("");
            txtTelefone.setText("");
            //ativar e desativar campos
            txtAcessorio.setEnabled(false);
            txtBairro.setEnabled(false);
            txtCelular.setEnabled(false);
            txtCidade.setEnabled(false);
            txtCliente.setEnabled(false);
            txtCodigoCliente.setEnabled(false);
            txtDataH.setEnabled(false);
            txtDefeito.setEnabled(false);
            txtEndereco.setEnabled(false);
            txtEquipamento.setEnabled(false);
            txtNServico.setEnabled(false);
            txtNotaF.setEnabled(false);
            txtObs.setEnabled(false);
            txtTelefone.setEnabled(false);
            // desativar o botao excluir
            btnExcluir.setEnabled(false);
            JOptionPane.showMessageDialog(null, "Registro excluido com sucesso!");
        } else {
            return;
        }
    }//GEN-LAST:event_btnExcluirActionPerformed

    private void btnGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGravarActionPerformed
        if (btnGravar.getText() == "Atualizar") {
            //alterar
            int linhaSelecionada = TabelaServ.getSelectedRow();
            Servico servico = new Servico();

            servico.setCodigoServico(Integer.parseInt(TabelaServ.getValueAt(linhaSelecionada, 0).toString()));//"Aqui é para modificação do id (Não pode ser alterado.)"
            servico.setStatus(CboxStatus.getSelectedItem().toString());
            servico.setEquipamento(txtEquipamento.getText());
            servico.setAcessorio(txtAcessorio.getText());
            servico.setDataHora(txtDataH.getText());
            servico.setNotaFiscal(txtNotaF.getText());
            servico.setDefeitoReclamar(txtDefeito.getText());
            servico.setCodigoCliente(Integer.parseInt(txtCodigoCliente.getText()));

            try {
                ServicoDAO sDao = new ServicoDAO();
                sDao.editar(servico);

            } catch (Exception e) {
                e.printStackTrace();
            }
            btnGravar.setEnabled(false);
        } else {
            //adiciona
            if (txtCodigoCliente.getText().equals("")) {
                JOptionPane.showMessageDialog(null, "O campo de código cliente não pode ficar em branco");
                txtCodigoCliente.requestFocus();
                return;
            }


            if (txtDataH.getText().equals("")) {
                JOptionPane.showMessageDialog(null, "O campo Data e Hora não pode ficar em branco");
                txtDataH.requestFocus();
                return;
            }

            if (txtNotaF.getText().equals("")) {
                JOptionPane.showMessageDialog(null, "O campo Nota Fiscal não pode ficar em branco");
                txtNotaF.requestFocus();
                return;
            }

            if (txtEquipamento.getText().equals("")) {
                JOptionPane.showMessageDialog(null, "O campo Equipamento não pode ficar em branco");
                txtEquipamento.requestFocus();
                return;
            }

            if (txtDefeito.getText().equals("")) {
                JOptionPane.showMessageDialog(null, "O campo Defeito a Reclamar não pode ficar em branco");
                txtDefeito.requestFocus();
                return;
            }

            servico.setCodigoCliente(Integer.parseInt(txtCodigoCliente.getText().toString()));
            servico.setStatus(CboxStatus.getSelectedItem().toString());
            servico.setDataHora(txtDataH.getText());
            servico.setNotaFiscal(txtNotaF.getText());
            servico.setAcessorio(txtAcessorio.getText());
            servico.setEquipamento(txtEquipamento.getText());
            servico.setDefeitoReclamar(txtDefeito.getText());


            ServicoDAO dao = null;

            try {
                dao = new ServicoDAO();
                // se caso ocorrer um erro ele vai entrar no catch
                txtCodigoCliente.getText();
                CboxStatus.getSelectedItem();
                txtDataH.getText();
                txtNotaF.getText();
                txtAcessorio.getText();
                txtEquipamento.getText();
                txtDefeito.getText();

            } catch (SQLException ex) {
                Logger.getLogger(Servicos.class.getName()).log(Level.SEVERE, null, ex);
            }
            try {
                dao.adiciona(servico);
                // se caso ocorrer um erro ele vai entrar no catch
                txtCodigoCliente.getText();
                CboxStatus.getSelectedItem();
                txtDataH.getText();
                txtNotaF.getText();
                txtAcessorio.getText();
                txtEquipamento.getText();
                txtDefeito.getText();
            } catch (SQLException ex) {
                Logger.getLogger(Servicos.class.getName()).log(Level.SEVERE, null, ex);
            }
            //fim adiciona
            //ativo e não ativo

            btnNaoGravar.setEnabled(false);
            btnGravar.setEnabled(false);
            btnIncluir.setEnabled(true);
            btnLocalizar.setEnabled(true);
            btnImprimir.setEnabled(true);
            btnFechar.setEnabled(true);
        }

}//GEN-LAST:event_btnGravarActionPerformed

    private void btnNaoGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNaoGravarActionPerformed
        txtAcessorio.setText("");
        txtBairro.setText("");
        txtCelular.setText("");
        txtCidade.setText("");
        txtCliente.setText("");
        txtCodigoCliente.setText("");
        txtDataH.setText("");
        txtDefeito.setText("");
        txtEndereco.setText("");
        txtEquipamento.setText("");
        txtNotaF.setText("");
        txtObs.setText("");
        txtTelefone.setText("");
        txtNServico.setText("");
        //desativar e ativa ou campos
        txtAcessorio.setEnabled(false);
        txtBairro.setEnabled(false);
        txtCelular.setEnabled(false);
        txtCidade.setEnabled(false);
        txtCliente.setEnabled(false);
        txtCodigoCliente.setEnabled(false);
        txtDataH.setEnabled(false);
        txtDefeito.setEnabled(false);
        txtEndereco.setEnabled(false);
        txtEquipamento.setEnabled(false);
        txtNotaF.setEnabled(false);
        txtObs.setEnabled(false);
        txtTelefone.setEnabled(false);
        txtNServico.setEnabled(false);
        CboxStatus.setEnabled(false);
        //ativar e desativar botões
        btnNaoGravar.setEnabled(false);
        btnGravar.setEnabled(false);
        btnIncluir.setEnabled(true);
        btnLocalizar.setEnabled(true);
        btnImprimir.setEnabled(true);
        btnFechar.setEnabled(true);
        btnBCodigo.setEnabled(false);
}//GEN-LAST:event_btnNaoGravarActionPerformed

    private void btnImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImprimirActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_btnImprimirActionPerformed

    private void btnFecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFecharActionPerformed
        this.dispose();
}//GEN-LAST:event_btnFecharActionPerformed

    private void btnBCodigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBCodigoActionPerformed
        if (btnLocalizar.getText().equals("Localizar")) {
            btnLocalizar.setText("Voltar");
            dadosCliente.setVisible(false);
            dadosServico.setVisible(false);
            Localizar.setVisible(true);
            btnIncluir.setEnabled(false);
        } else {
            btnLocalizar.setText("Localizar");
            dadosCliente.setVisible(true);
            Localizar.setVisible(false);
            btnIncluir.setEnabled(true);
        }
        btnExcluir.setEnabled(false);
        btnFechar.setEnabled(true);
        btnNaoGravar.setEnabled(false);
        btnGravar.setEnabled(false);
        btnLocalizar.setEnabled(true);
        btnGravar.setText("Gravar");
    }//GEN-LAST:event_btnBCodigoActionPerformed

    private void txtCodigoClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCodigoClienteActionPerformed
    }//GEN-LAST:event_txtCodigoClienteActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
    }//GEN-LAST:event_formWindowOpened

    private void txtPesquisaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPesquisaKeyReleased
//        modeloServ.setNumRows(0);
//
//        try {
//            ServicoDAO sDao = new ServicoDAO();
//            ArrayList<Servico> servico = sDao.retornaServicoPorNome(txt);
//
//            for (Cliente c : cliente) {
//                modelo.addRow(new String[]{Integer.toString(c.getCodigo()), c.getNome(), c.getApelido(), c.getCliente(), c.getFornecedor(), c.getAtivo(), c.getTipoPessoa(), c.getEndereco(), c.getBairro(), c.getCidade(), c.getCep(), c.getUf(), c.getCgf(), c.getFone1(), c.getFone2(), c.getFax(), c.getCelular(), c.getCnpj(), c.getObs(), Float.toString(c.getLimiteCredito()), Float.toString(c.getDebitoPendente()), Float.toString(c.getSaldoAtual())});
//
//            }
//        } catch (SQLException ex) {
//            ex.printStackTrace();
//
//        }
}//GEN-LAST:event_txtPesquisaKeyReleased

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        if (evt.getClickCount() == 2) {
            if (jTable1.getSelectedRow() != -1) {
                int linhaSelecionada = jTable1.getSelectedRow();
                txtCodigoCliente.setText((modelo.getValueAt(linhaSelecionada, 0).toString()));
                txtCliente.setText(modelo.getValueAt(linhaSelecionada, 1).toString());
                txtTelefone.setText(modelo.getValueAt(linhaSelecionada, 13).toString());
                txtCelular.setText(modelo.getValueAt(linhaSelecionada, 16).toString());
                txtEndereco.setText(modelo.getValueAt(linhaSelecionada, 7).toString());
                txtCidade.setText(modelo.getValueAt(linhaSelecionada, 9).toString());
                txtBairro.setText(modelo.getValueAt(linhaSelecionada, 8).toString());
                txtObs.setText(modelo.getValueAt(linhaSelecionada, 18).toString());

                if (btnLocalizar.getText().equals("Localizar")) {
                    dadosCliente.setVisible(false);
                    LocalizarServico.setVisible(true);
                    btnIncluir.setEnabled(false);
                } else {
                    btnLocalizar.setText("Localizar");
                    dadosCliente.setVisible(true);
                    dadosServico.setVisible(true);
                    LocalizarServico.setVisible(false);
                    btnIncluir.setEnabled(true);
                }
                //data e hora
                SimpleDateFormat dataf = new SimpleDateFormat("dd/MM/yyyy 'e' HH:mm:ss");
                data = new Date();
                txtDataH.setText(dataf.format(data));
                //ativar e desativar botões
                txtAcessorio.setEnabled(true);
                txtBairro.setEnabled(true);
                txtCelular.setEnabled(true);
                txtCidade.setEnabled(true);
                txtCliente.setEnabled(true);
                txtCodigoCliente.setEnabled(true);
                txtDataH.setEnabled(false);
                txtDefeito.setEnabled(true);
                txtEndereco.setEnabled(true);
                txtEquipamento.setEnabled(true);
                txtNotaF.setEnabled(true);
                txtObs.setEnabled(true);
                txtTelefone.setEnabled(true);
                txtNServico.setEnabled(false);
                CboxStatus.setEnabled(true);
                Localizar.setVisible(false);
                btnGravar.setEnabled(true);
                btnNaoGravar.setEnabled(true);
            }
        }
}//GEN-LAST:event_jTable1MouseClicked

    private void jTable1MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseEntered
}//GEN-LAST:event_jTable1MouseEntered

    private void jTable1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MousePressed
}//GEN-LAST:event_jTable1MousePressed

    private void jScrollPane2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jScrollPane2MouseClicked
}//GEN-LAST:event_jScrollPane2MouseClicked

    private void TabelaServMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TabelaServMouseClicked
        if (evt.getClickCount() == 2) {
            if (TabelaServ.getSelectedRow() != -1) {
                int linhaSelecionada = TabelaServ.getSelectedRow();

                txtNServico.setText((modeloServ.getValueAt(linhaSelecionada, 0).toString()));
                CboxStatus.setSelectedItem(modeloServ.getValueAt(linhaSelecionada, 1).toString());
                txtEquipamento.setText(modeloServ.getValueAt(linhaSelecionada, 2).toString());
                txtAcessorio.setText(modeloServ.getValueAt(linhaSelecionada, 3).toString());
                txtDataH.setText(modeloServ.getValueAt(linhaSelecionada, 4).toString());// não entra!
                txtNotaF.setText(modeloServ.getValueAt(linhaSelecionada, 5).toString());
                txtDefeito.setText(modeloServ.getValueAt(linhaSelecionada, 6).toString());
                txtCodigoCliente.setText(modeloServ.getValueAt(linhaSelecionada, 7).toString());
                try {
                    ServicoDAO cDao = new ServicoDAO();
                    ArrayList<Cliente> cliente = cDao.retornaCamposPorCodigo(txtCodigoCliente.getText());

                    for (Cliente c : cliente) {
                        txtCliente.setText(c.getNome());
                        txtTelefone.setText(c.getFone1());
                        txtCelular.setText(c.getCelular());
                        txtEndereco.setText(c.getEndereco());
                        txtCidade.setText(c.getCidade());
                        txtBairro.setText(c.getBairro());
                        txtObs.setText(c.getObs());
                    }
                } catch (SQLException ex) {
                    ex.printStackTrace();
                }

                if (btnLocalizar.getText().equals("Localizar")) {
                    dadosCliente.setVisible(false);
                    LocalizarServico.setVisible(true);
                    btnIncluir.setEnabled(false);
                } else {
                    btnLocalizar.setText("Localizar");
                    dadosCliente.setVisible(true);
                    dadosServico.setVisible(true);
                    LocalizarServico.setVisible(false);
                    btnIncluir.setEnabled(true);
                }
                //ativar e desativar botões
                txtAcessorio.setEnabled(true);
                txtBairro.setEnabled(true);
                txtCelular.setEnabled(true);
                txtCidade.setEnabled(true);
                txtCliente.setEnabled(true);
                txtCodigoCliente.setEnabled(false);
                txtDataH.setEnabled(false);
                txtDefeito.setEnabled(true);
                txtEndereco.setEnabled(true);
                txtEquipamento.setEnabled(true);
                txtNotaF.setEnabled(true);
                txtObs.setEnabled(true);
                txtTelefone.setEnabled(true);
                txtNServico.setEnabled(false);
                CboxStatus.setEnabled(true);
                Localizar.setVisible(false);
                btnGravar.setEnabled(false);
                btnExcluir.setEnabled(true);
                btnGravar.setText("Atualizar");
            }
        }
    }//GEN-LAST:event_TabelaServMouseClicked

    private void TabelaServMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TabelaServMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_TabelaServMouseEntered

    private void TabelaServMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TabelaServMousePressed
        // TODO add your handling code here:
    }//GEN-LAST:event_TabelaServMousePressed

    private void jScrollPane4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jScrollPane4MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jScrollPane4MouseClicked

    private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
        // DIMENSÕES DA TELA
        // Recupera o tamanho da tela
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        // Ajusta o tamanho da janela (JFrame)
        setSize(new java.awt.Dimension(732, 636));
        // Ajusta a localização da janela, dependendo do tamanho da janela em
        // relação ao tamanho da tela
        setLocation((screenSize.width - 1000) / 2, (screenSize.height - 800) / 2);
        //ativar e desativar botões
        btnIncluir.setEnabled(true);
        btnLocalizar.setEnabled(true);
        btnExcluir.setEnabled(false);
        btnGravar.setEnabled(false);
        btnNaoGravar.setEnabled(false);
        btnImprimir.setEnabled(false);
        //desativar e ativa ou campos
        txtAcessorio.setEnabled(false);
        txtBairro.setEnabled(false);
        txtCelular.setEnabled(false);
        txtCidade.setEnabled(false);
        txtCliente.setEnabled(false);
        txtCodigoCliente.setEnabled(false);
        txtDataH.setEnabled(false);
        txtDefeito.setEnabled(false);
        txtEndereco.setEnabled(false);
        txtEquipamento.setEnabled(false);
        txtNotaF.setEnabled(false);
        txtObs.setEnabled(false);
        txtTelefone.setEnabled(false);
        txtNServico.setEnabled(false);
        CboxStatus.setEnabled(false);
        Localizar.setVisible(false);
        LocalizarServico.setVisible(false);
        //ativa e desativar botões
        btnBCodigo.setEnabled(false);
        //TABELA DE BUSCA DE CLIENTE
        String[] colunas = new String[]{"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
        String[][] dados = new String[][]{};


        modelo = new DefaultTableModel(dados, colunas) {

            public boolean isCellEditable(int row, int col) {
                return false;
            }
        };
        jTable1.setModel(modelo);
        jTable1.getTableHeader().getColumnModel().getColumn(0).setHeaderValue("Código");
        jTable1.getTableHeader().getColumnModel().getColumn(1).setHeaderValue("Nome");
        jTable1.getTableHeader().getColumnModel().getColumn(2).setHeaderValue("Apelido");
        jTable1.getTableHeader().getColumnModel().getColumn(3).setHeaderValue("Fornecedor");
        jTable1.getTableHeader().getColumnModel().getColumn(4).setHeaderValue("Cliente");
        jTable1.getTableHeader().getColumnModel().getColumn(5).setHeaderValue("Ativo");
        jTable1.getTableHeader().getColumnModel().getColumn(6).setHeaderValue("Tipo de Pessoa");
        jTable1.getTableHeader().getColumnModel().getColumn(7).setHeaderValue("Endereço");
        jTable1.getTableHeader().getColumnModel().getColumn(8).setHeaderValue("Bairro");
        jTable1.getTableHeader().getColumnModel().getColumn(9).setHeaderValue("Cidade");
        jTable1.getTableHeader().getColumnModel().getColumn(10).setHeaderValue("CEP");
        jTable1.getTableHeader().getColumnModel().getColumn(11).setHeaderValue("UF");
        jTable1.getTableHeader().getColumnModel().getColumn(12).setHeaderValue("Inscrição Estadual");
        jTable1.getTableHeader().getColumnModel().getColumn(13).setHeaderValue("Telefone 1");
        jTable1.getTableHeader().getColumnModel().getColumn(14).setHeaderValue("Telefone 2");
        jTable1.getTableHeader().getColumnModel().getColumn(15).setHeaderValue("Fax");
        jTable1.getTableHeader().getColumnModel().getColumn(16).setHeaderValue("Celular");
        jTable1.getTableHeader().getColumnModel().getColumn(17).setHeaderValue("CNPJ");
        jTable1.getTableHeader().getColumnModel().getColumn(18).setHeaderValue("OBS.");

        jTable1.getTableHeader().getColumnModel().getColumn(0).setMinWidth(40);
        jTable1.getTableHeader().getColumnModel().getColumn(1).setMinWidth(180);
        jTable1.getTableHeader().getColumnModel().getColumn(2).setMinWidth(130);
        jTable1.getTableHeader().getColumnModel().getColumn(3).setMinWidth(40);
        jTable1.getTableHeader().getColumnModel().getColumn(4).setMinWidth(40);
        jTable1.getTableHeader().getColumnModel().getColumn(5).setMinWidth(40);
        jTable1.getTableHeader().getColumnModel().getColumn(6).setMinWidth(40);
        jTable1.getTableHeader().getColumnModel().getColumn(7).setMinWidth(180);
        jTable1.getTableHeader().getColumnModel().getColumn(8).setMinWidth(130);
        jTable1.getTableHeader().getColumnModel().getColumn(9).setMinWidth(150);
        jTable1.getTableHeader().getColumnModel().getColumn(10).setMinWidth(70);
        jTable1.getTableHeader().getColumnModel().getColumn(11).setMinWidth(40);
        jTable1.getTableHeader().getColumnModel().getColumn(12).setMinWidth(110);
        jTable1.getTableHeader().getColumnModel().getColumn(13).setMinWidth(100);
        jTable1.getTableHeader().getColumnModel().getColumn(14).setMinWidth(100);
        jTable1.getTableHeader().getColumnModel().getColumn(15).setMinWidth(100);
        jTable1.getTableHeader().getColumnModel().getColumn(16).setMinWidth(100);
        jTable1.getTableHeader().getColumnModel().getColumn(17).setMinWidth(150);
        jTable1.getTableHeader().getColumnModel().getColumn(18).setMinWidth(200);

        jTable1.setPreferredScrollableViewportSize(new Dimension(2300, 0));

        // retorna todos os clientes para a tabela modelo.
        try {
            ClienteDAO clienteDao = new ClienteDAO();
            ArrayList<Cliente> cliente = clienteDao.retornaTodosClientes();

            for (Cliente c : cliente) {
                modelo.addRow(new String[]{Integer.toString(c.getCodigo()), c.getNome(), c.getApelido(), c.getCliente(), c.getFornecedor(), c.getAtivo(), c.getTipoPessoa(), c.getEndereco(), c.getBairro(), c.getCidade(), c.getCep(), c.getUf(), c.getCgf(), c.getFone1(), c.getFone2(), c.getFax(), c.getCelular(), c.getCnpj(), c.getObs()});
            }

        } catch (SQLException ex) {
            ex.printStackTrace();
        }

        //TABELA DE BUSCA DE SERVIÇOS
        String[] colunas2 = new String[]{"", "", "", "", "", "", "", "", ""};
        String[][] dados2 = new String[][]{};


        modeloServ = new DefaultTableModel(dados2, colunas2) {

            public boolean isCellEditable(int row, int col) {
                return false;
            }
        };
        TabelaServ.setModel(modeloServ);
        TabelaServ.getTableHeader().getColumnModel().getColumn(0).setHeaderValue("Código");
        TabelaServ.getTableHeader().getColumnModel().getColumn(1).setHeaderValue("Status");
        TabelaServ.getTableHeader().getColumnModel().getColumn(2).setHeaderValue("Equipamento");
        TabelaServ.getTableHeader().getColumnModel().getColumn(3).setHeaderValue("Acessorios");
        TabelaServ.getTableHeader().getColumnModel().getColumn(4).setHeaderValue("Data e Hora");
        TabelaServ.getTableHeader().getColumnModel().getColumn(5).setHeaderValue("Nota Fiscal");
        TabelaServ.getTableHeader().getColumnModel().getColumn(6).setHeaderValue("Defeito a Reclamar");
        TabelaServ.getTableHeader().getColumnModel().getColumn(7).setHeaderValue("Cód. Cliente");
        TabelaServ.getTableHeader().getColumnModel().getColumn(8).setHeaderValue("Nome do Cliente");

        TabelaServ.getTableHeader().getColumnModel().getColumn(0).setMinWidth(10);
        TabelaServ.getTableHeader().getColumnModel().getColumn(1).setMinWidth(40);
        TabelaServ.getTableHeader().getColumnModel().getColumn(2).setMinWidth(80);
        TabelaServ.getTableHeader().getColumnModel().getColumn(3).setMinWidth(200);
        TabelaServ.getTableHeader().getColumnModel().getColumn(4).setMinWidth(70);
        TabelaServ.getTableHeader().getColumnModel().getColumn(5).setMinWidth(40);
        TabelaServ.getTableHeader().getColumnModel().getColumn(6).setMinWidth(130);
        TabelaServ.getTableHeader().getColumnModel().getColumn(7).setMinWidth(30);
        TabelaServ.getTableHeader().getColumnModel().getColumn(8).setMinWidth(130);

        TabelaServ.setPreferredScrollableViewportSize(new Dimension(1000, 0));

        // retorna todos os serviços para a tabela modelo.
        try {
            ServicoDAO servicoDao = new ServicoDAO();
            ArrayList<Servico> servico = servicoDao.retornaTodosServicos();

            modeloServ.setNumRows(0);

            for (Servico s : servico) {
                // para inserir o codigo do cliente que faz parte de outro metodo na classeDao
                modeloServ.addRow(new String[]{Integer.toString(s.getCodigoServico()), s.getStatus(), s.getEquipamento(), s.getAcessorio(), s.getDataHora(), s.getNotaFiscal(), s.getDefeitoReclamar(), Integer.toString(s.getCodigoCliente()), s.getCliente()});
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }//GEN-LAST:event_formInternalFrameOpened

    private void CboxStatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CboxStatusActionPerformed
        btnGravar.setEnabled(true);
    }//GEN-LAST:event_CboxStatusActionPerformed

    private void txtCodigoClienteKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCodigoClienteKeyTyped
        btnGravar.setEnabled(true);
    }//GEN-LAST:event_txtCodigoClienteKeyTyped

    private void txtNotaFKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNotaFKeyTyped
        btnGravar.setEnabled(true);
    }//GEN-LAST:event_txtNotaFKeyTyped

    private void txtAcessorioKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtAcessorioKeyTyped
        btnGravar.setEnabled(true);
    }//GEN-LAST:event_txtAcessorioKeyTyped

    private void txtEquipamentoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEquipamentoKeyTyped
        btnGravar.setEnabled(true);
    }//GEN-LAST:event_txtEquipamentoKeyTyped

    private void txtDefeitoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDefeitoKeyTyped
        btnGravar.setEnabled(true);
    }//GEN-LAST:event_txtDefeitoKeyTyped

    private void cPesquisaServActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cPesquisaServActionPerformed
        modeloServ.setNumRows(0);

        try {
            ServicoDAO sDao = new ServicoDAO();
            ArrayList<Servico> servico = sDao.retornaServicoPorStatus(cPesquisaServ.getSelectedItem().toString());

            for (Servico s : servico) {
                modeloServ.addRow(new String[]{Integer.toString(s.getCodigoServico()), s.getStatus(), s.getEquipamento(), s.getAcessorio(), s.getDataHora(), s.getNotaFiscal(), s.getDefeitoReclamar(), Integer.toString(s.getCodigoCliente()), s.getCliente()});

            }
        } catch (SQLException ex) {
            ex.printStackTrace();

        }
    }//GEN-LAST:event_cPesquisaServActionPerformed

    private void txtPesquisaNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPesquisaNomeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtPesquisaNomeActionPerformed

    private void txtPesquisaNomeKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPesquisaNomeKeyReleased
        modeloServ.setNumRows(0);

        try {
            ServicoDAO sDao = new ServicoDAO();
            ArrayList<Servico> servico = sDao.retornaServicoPorNome(txtPesquisaNome.getText());

            for (Servico s : servico) {
                modeloServ.addRow(new String[]{Integer.toString(s.getCodigoServico()), s.getStatus(), s.getEquipamento(), s.getAcessorio(), s.getDataHora(), s.getNotaFiscal(), s.getDefeitoReclamar(), Integer.toString(s.getCodigoCliente()), s.getCliente()});
            }
        } catch (SQLException ex) {
            ex.printStackTrace();

        }
    }//GEN-LAST:event_txtPesquisaNomeKeyReleased

    private void txtCodigoClienteKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCodigoClienteKeyReleased
        try {
            ServicoDAO cDao = new ServicoDAO();
            ArrayList<Cliente> cliente = cDao.retornaCamposPorCodigo(txtCodigoCliente.getText());

            for (Cliente c : cliente) {
                txtCliente.setText(c.getNome());
                txtTelefone.setText(c.getFone1());
                txtCelular.setText(c.getCelular());
                txtEndereco.setText(c.getEndereco());
                txtCidade.setText(c.getCidade());
                txtBairro.setText(c.getBairro());
                txtObs.setText(c.getObs());
            }
        } catch (SQLException ex) {
            ex.printStackTrace();

        }
    }//GEN-LAST:event_txtCodigoClienteKeyReleased

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Servicos().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox CboxStatus;
    private javax.swing.JPanel Localizar;
    private javax.swing.JPanel LocalizarServico;
    private javax.swing.JTable TabelaServ;
    private javax.swing.JButton btnBCodigo;
    private javax.swing.JButton btnExcluir;
    private javax.swing.JButton btnFechar;
    private javax.swing.JButton btnGravar;
    private javax.swing.JButton btnImprimir;
    private javax.swing.JButton btnIncluir;
    private javax.swing.JButton btnLocalizar;
    private javax.swing.JButton btnNaoGravar;
    private javax.swing.JComboBox cPesquisaServ;
    private javax.swing.JPanel dadosCliente;
    private javax.swing.JPanel dadosServico;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField txtAcessorio;
    private javax.swing.JTextField txtBairro;
    private javax.swing.JTextField txtCelular;
    private javax.swing.JTextField txtCidade;
    private javax.swing.JTextField txtCliente;
    private javax.swing.JTextField txtCodigoCliente;
    private javax.swing.JTextField txtDataH;
    private javax.swing.JTextField txtDefeito;
    private javax.swing.JTextField txtEndereco;
    private javax.swing.JTextField txtEquipamento;
    private javax.swing.JFormattedTextField txtNServico;
    private javax.swing.JTextField txtNotaF;
    private javax.swing.JTextArea txtObs;
    private javax.swing.JTextField txtPesquisa;
    private javax.swing.JTextField txtPesquisaNome;
    private javax.swing.JTextField txtTelefone;
    // End of variables declaration//GEN-END:variables
}
